package org.example.test.entity;

import com.fasterxml.jackson.annotation.JsonIgnore;
import lombok.Data;
import org.example.common.entity.AbstractEntity;

import javax.persistence.*;
import java.util.List;

/**
 * 班级
 *
 * @author jzq
 * @date 2022/8/19 13:37
 */
@SuppressWarnings({"all"})
@Data
@Entity
@Table(name = "test_clazz")
public class Clazz extends AbstractEntity {

    private String clazzName;

    @ManyToMany(cascade = CascadeType.ALL)
    @JoinTable(name = "test_clazz_student",
            joinColumns =  @JoinColumn(name = "clazz_id"),
            inverseJoinColumns = @JoinColumn(name = "student_id")
           )
    private List<Student> students;

    @ManyToOne(cascade = CascadeType.ALL,fetch = FetchType.EAGER)
    @JoinColumn(name = "school_id",insertable = false, updatable = false)
    @JsonIgnore
    private School school;

}
